import { defineStore } from 'pinia'

export const useUserStore = defineStore({
  id: 'user',
  state: () => ({
    token: '',  // 没有token就是没登录
    nick: '',  // 用户昵称
    phone: '',  // 登录手机号
    uid: '',  // 用户id
  }),
  getters: {
    isLogin: state => !!state.token
  },
  actions: {
    clear() {
      this.token = ''
      this.nick = ''
      this.phone = ''
      this.uid = ''
    },
  },
  // 开启持久化
  persist: true,
})